package com.wbt.jdk;

import java.util.concurrent.CountDownLatch;
import java.util.function.Consumer;

public class VolatileTest {

    private static volatile int i = 0;

    public static void main(String[] args) {
        CountDownLatch doneSignal = new CountDownLatch(3);
        new Thread(() -> {
            for (int j=0;j<100000;j++){
                i++;
                if(i>200900){
                    System.out.println("t1:" + i);
                }

            }
            System.out.println("t1:" + i);
        }).start();
        new Thread(() -> {
            for (int j=0;j<100000;j++){
                i++;
                if(i>200900){
                    System.out.println("t2:" + i);
                }
            }
            System.out.println("t2:" + i);
        }).start();
        new Thread(() -> {
            for (int j=0;j<100000;j++){
                i++;
                if(i>200900){
                    System.out.println("t3:" + i);
                }
            }
            System.out.println("t3:" + i);
        }).start();




    }

}
